<?php

require __DIR__ . '/../../vendor/autoload.php';

use Parse\StringParser;
use Parse\ParseException;

{
    $parser = new StringParser("Hello World");
    var_dump($parser->match("Hello World!")
             === array("match" => "Hello World",
                       "rest" => "!"));
    try {
        $parser = new StringParser(123);
        var_dump(false);
    } catch (ParseException $e) {
        var_dump(true);
    }
    try {
        $parser = new StringParser("string", false);
        var_dump(false);
    } catch (ParseException $e) {
        var_dump(true);
    }

    // Testing that we get an error if we don't match!
    try {
        $parser = new StringParser("/");
        $parser->match("abcd");
        var_dump(false);
    } catch (ParseException $e) {
        var_dump(true);
    }
}
